﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
namespace Lawyer.Web.ActivityInfo
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtActivityID.Text.Trim().Length==0)
			{
				strErr+="ActivityID不能为空！\\n";	
			}
			if(this.txtType.Text.Trim().Length==0)
			{
				strErr+="Type不能为空！\\n";	
			}
			if(this.txtTitle.Text.Trim().Length==0)
			{
				strErr+="Title不能为空！\\n";	
			}
			if(this.txtDetail.Text.Trim().Length==0)
			{
				strErr+="Detail不能为空！\\n";	
			}
			if(this.txtLawyerID.Text.Trim().Length==0)
			{
				strErr+="LawyerID不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtStartDate.Text))
			{
				strErr+="StartDate格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtEndDate.Text))
			{
				strErr+="EndDate格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtFee.Text))
			{
				strErr+="Fee格式错误！\\n";	
			}
			if(this.txtArchiveID.Text.Trim().Length==0)
			{
				strErr+="ArchiveID不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtIsArchive.Text))
			{
				strErr+="IsArchive格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtStatus.Text))
			{
				strErr+="Status格式错误！\\n";	
			}
			if(this.txtCreatedBy.Text.Trim().Length==0)
			{
				strErr+="CreatedBy不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtCreatedDate.Text))
			{
				strErr+="CreatedDate格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string ActivityID=this.txtActivityID.Text;
			string Type=this.txtType.Text;
			string Title=this.txtTitle.Text;
			string Detail=this.txtDetail.Text;
			string LawyerID=this.txtLawyerID.Text;
			DateTime StartDate=DateTime.Parse(this.txtStartDate.Text);
			DateTime EndDate=DateTime.Parse(this.txtEndDate.Text);
			decimal Fee=decimal.Parse(this.txtFee.Text);
			string ArchiveID=this.txtArchiveID.Text;
			int IsArchive=int.Parse(this.txtIsArchive.Text);
			int Status=int.Parse(this.txtStatus.Text);
			string CreatedBy=this.txtCreatedBy.Text;
			DateTime CreatedDate=DateTime.Parse(this.txtCreatedDate.Text);

			Lawyer.Model.ActivityInfo model=new Lawyer.Model.ActivityInfo();
			model.ActivityID=ActivityID;
			model.Type=Type;
			model.Title=Title;
			model.Detail=Detail;
			model.LawyerID=LawyerID;
			model.StartDate=StartDate;
			model.EndDate=EndDate;
			model.Fee=Fee;
			model.ArchiveID=ArchiveID;
			model.IsArchive=IsArchive;
			model.Status=Status;
			model.CreatedBy=CreatedBy;
			model.CreatedDate=CreatedDate;

			Lawyer.BLL.ActivityInfo bll=new Lawyer.BLL.ActivityInfo();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
